home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / misc / gms_dev.lha / GMSDev / Source / Asm / Blitter / RamboWorm.s < prev    next >
Encoding:
Text File  |  1998-05-16  |  6.3 KB  |  280 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;This example blits a Worm from an IFF file onto a double buffered screen.
  3. ;The RESTORE mode is used to put the background back.
  4.  
  5.     INCDIR    "GMSDev:Includes/"
  6.     INCLUDE    "dpkernel/dpkernel.i"
  7.  
  8.     SECTION    "Demo",CODE
  9.  
  10. ;===========================================================================;
  11. ;                             INITIALISE DEMO
  12. ;===========================================================================;
  13.  
  14. Start:    STARTDPK
  15.  
  16.     MOVEM.L    A0-A6/D1-D7,-(SP)
  17.     move.l    DPKBase(pc),a6
  18.     lea    BackgroundFile(pc),a0
  19.     moveq    #ID_PICTURE,d0
  20.     CALL    Load
  21.     move.l    d0,PIC_Background
  22.     beq    .Exit
  23.  
  24.     ;Get screen.
  25.  
  26.     moveq    #ID_SCREEN,d0
  27.     CALL    Get
  28.     move.l    d0,Screen
  29.     beq    .Exit
  30.  
  31.     ;Copy picture details to screen.
  32.  
  33.     move.l    PIC_Background(pc),a0
  34.     move.l    PIC_Bitmap(a0),a2
  35.     move.l    Screen(pc),a1
  36.     move.l    #SCR_DBLBUFFER,GS_Attrib(a1)
  37.     CALL    CopyStructure
  38.  
  39. ;---------------------------------------------------------------------------;
  40. ;Initialise the screen.
  41.  
  42.     move.l    Screen(pc),a0    ;Initialise the screen.
  43.     sub.l    a1,a1
  44.     CALL    Init
  45.     tst.l    d0
  46.     beq    .Exit
  47.  
  48.     move.l    PIC_Background(pc),a0
  49.     move.l    PIC_Bitmap(a0),a0
  50.     move.l    Screen(pc),a1
  51.     move.l    GS_Bitmap(a1),a1
  52.     CALL    Copy
  53.  
  54.     move.l    BLTBase(pc),a6
  55.     move.l    Screen(pc),a0
  56.     moveq    #BUFFER2,d0
  57.     moveq    #BUFFER1,d1
  58.     CALL    bltCopyBuffer
  59.  
  60. ;---------------------------------------------------------------------------;
  61. ;Initialise the restore object.
  62.  
  63.     move.l    DPKBase(pc),a6
  64.     lea    RestoreTags(pc),a0
  65.     move.l    Screen(pc),a1    ;a1 = Screen.
  66.     CALL    Init    ;>> = Initialise the restore list.
  67.     tst.l    d0    ;d0 = Check for errors.
  68.     beq.s    .Exit    ;>> = Error, exit.
  69.  
  70. ;---------------------------------------------------------------------------;
  71. ;Load the bob file in.  This contains the graphics data that we are
  72. ;going to draw to the screen.
  73.  
  74.     lea    BBT_Rambo(pc),a0    ;a0 = Object.
  75.     move.l    Screen(pc),a1    ;a1 = Container.
  76.     move.l    GS_Bitmap(a1),a2
  77.     move.l    BMP_Palette(a2),BobPalette
  78.     CALL    Init    ;>> = Initialise bob to screen.
  79.     tst.l    d0
  80.     beq.s    .Exit
  81.  
  82. ;---------------------------------------------------------------------------;
  83. ;Load sounds and initialise joydata object.
  84.  
  85.     lea    SMT_Rambo(pc),a0
  86.     sub.l    a1,a1
  87.     CALL    Init
  88.     tst.l    d0
  89.     beq.s    .Exit
  90.  
  91.     moveq    #ID_JOYDATA,d0    ;Get joydata structure.
  92.     CALL    Get
  93.     move.l    d0,JoyData
  94.     beq.s    .Exit
  95.     move.l    d0,a0    ;Initialise the joydata structure.
  96.     sub.l    a1,a1
  97.     CALL    Init
  98.     tst.l    d0
  99.     beq.s    .Exit
  100.  
  101. ;---------------------------------------------------------------------------;
  102. ;Display our screen and start the demo.
  103.  
  104.     move.l    Screen(pc),a0
  105.     CALL    Display
  106.  
  107.     bsr.s    Main
  108.  
  109. ;---------------------------------------------------------------------------;
  110. ;Free the allocations.
  111.  
  112. .Exit    move.l    DPKBase(pc),a6
  113.     move.l    JoyData(pc),a0
  114.     CALL    Free
  115.     move.l    SND_Rambo(pc),a0
  116.     CALL    Free
  117.     move.l    BOB_Rambo(pc),a0
  118.     CALL    Free
  119.     move.l    Restore(pc),a0
  120.     CALL    Free
  121.     move.l    PIC_Background(pc),a0
  122.     CALL    Free
  123.     move.l    Screen(pc),a0
  124.     CALL    Free
  125.     MOVEM.L    (SP)+,A0-A6/D1-D7
  126.     moveq    #ERR_OK,d0
  127.     rts
  128.  
  129. ;===========================================================================;
  130. ;                                MAIN LOOP
  131. ;===========================================================================;
  132.  
  133. SPEED      =    5
  134. FIRESPEED =    0
  135.  
  136. Main:    moveq    #$00,d7
  137.  
  138. .Loop    move.l    DPKBase(pc),a6    ;a6 = DPKBase
  139.     move.l    Restore(pc),a0    ;a0 = Restore object.
  140.     CALL    Activate    ;>> = Restore the backgrounds.
  141.  
  142.     move.l    BOB_Rambo(pc),a0    ;a0 = Bob.
  143.     CALL    Draw    ;>> = Blit the bob.
  144.  
  145.     move.l    SCRBase(pc),a6    ;a6 = SCRBase.
  146.     CALL    scrWaitAVBL    ;>> = Wait for vertical blank.
  147.     move.l    Screen(pc),a0    ;a0 = Screen
  148.     CALL    scrSwapBuffers    ;>> = Swap video memory buffers.
  149.  
  150.     addq.w    #1,d7
  151.  
  152.     move.l    DPKBase(pc),a6
  153.     move.l    BOB_Rambo(pc),a1
  154.     tst.b    FireState
  155.     bne.s    .FireOn
  156.  
  157.     cmp.w    #SPEED,d7
  158.     ble.s    .Move
  159.     moveq    #$00,d7
  160.     addq.w    #1,BOB_Frame(a1)
  161.     cmp.w    #9,BOB_Frame(a1)
  162.     blt.s    .Move
  163.     clr.w    BOB_Frame(a1)
  164.     bra.s    .Move
  165.  
  166. .FireOn    cmp.w    #FIRESPEED,d7
  167.     ble.s    .Move
  168.     moveq    #$00,d7
  169.     cmp.w    #10,BOB_Frame(a1)
  170.     bge.s    .On
  171.     move.w    #9,BOB_Frame(a1)
  172.  
  173. .On    addq.w    #1,BOB_Frame(a1)
  174.     cmp.w    #13,BOB_Frame(a1)
  175.     blt.s    .Move
  176.     clr.w    BOB_Frame(a1)
  177.     clr.b    FireState
  178.     move.l    SND_Rambo(pc),a0
  179.     CALL    Activate
  180.  
  181. .Move    move.l    JoyData(pc),a0
  182.     CALL    Query
  183.     move.l    JoyData(pc),a0
  184.     move.l    BOB_Rambo(pc),a1
  185.     move.w    JD_XChange(a0),d0
  186.     add.w    d0,BOB_XCoord(a1)
  187.     move.w    JD_YChange(a0),d0
  188.     add.w    d0,BOB_YCoord(a1)
  189.     move.l    JD_Buttons(a0),d0
  190.     btst    #JB_LMB,d0
  191.     beq.s    .chkRMB
  192.     st    FireState    ;Set fire to on.
  193.  
  194. .chkRMB    btst    #JB_RMB,d0
  195.     beq    .Loop
  196.     rts
  197.  
  198. FireState:
  199.     dc.b    0
  200.     even
  201.  
  202. ;===========================================================================;
  203. ;                                  DATA
  204. ;===========================================================================;
  205.  
  206. JoyData:    dc.l  0
  207. Screen:        dc.l  0
  208. PIC_Background:    dc.l  0
  209. BackgroundFile:    FILENAME "GMS:demos/data/PIC.Green"
  210.  
  211. ;---------------------------------------------------------------------------;
  212.  
  213. RestoreTags:    dc.l  TAGS_RESTORE
  214. Restore:    dc.l  0
  215.         dc.l  RSA_Entries,1
  216.         dc.l  TAGEND
  217.  
  218. ;---------------------------------------------------------------------------;
  219.  
  220. BBT_Rambo:    dc.l  TAGS_BOB
  221. BOB_Rambo:    dc.l  0
  222.         dc.l  BBA_GfxCoords,BobFrames
  223.         dc.l  BBA_Width,32
  224.         dc.l  BBA_Height,24
  225.         dc.l  BBA_XCoord,150
  226.         dc.l  BBA_YCoord,150
  227.         dc.l  BBA_ClipLX,32
  228.         dc.l  BBA_ClipRX,320-32
  229.         dc.l  BBA_ClipTY,32
  230.         dc.l  BBA_ClipBY,256-32
  231.         dc.l  BBA_Attrib,BBF_RESTORE|BBF_CLIP|BBF_GENMASKS
  232.         dc.l    BBA_SourceTags,ID_PICTURE
  233.         dc.l    PCA_Source,BobFile
  234.         dc.l      PCA_BitmapTags,0
  235.         dc.l      BMA_MemType,MEM_BLIT
  236.         dc.l      BMA_Palette
  237. BobPalette:    dc.l      0
  238.         dc.l      TAGEND,0
  239.         dc.l    TAGEND,0
  240.         dc.l  TAGEND
  241.  
  242. BobFrames:    dc.w    0,00   ;0 GraphicX / GraphicY
  243.         dc.w   32,00   ;1 ...
  244.         dc.w   64,00   ;2
  245.         dc.w   96,00   ;3
  246.         dc.w  128,00   ;4
  247.         dc.w  160,00   ;5
  248.         dc.w  192,00   ;6
  249.         dc.w  224,00   ;7
  250.         dc.w  256,00   ;8
  251.         dc.w  288,00   ;9
  252.         dc.w    0,48   ;10
  253.         dc.w   32,48   ;11
  254.         dc.w   64,48   ;12
  255.         dc.l  -1
  256.  
  257. BobFile:    FILENAME "GMS:demos/data/PIC.Rambo"
  258.  
  259. ;---------------------------------------------------------------------------;
  260.  
  261. SMT_Rambo:    dc.l  TAGS_SOUND
  262. SND_Rambo:    dc.l  0
  263.         dc.l  SA_Octave,OCT_C2S
  264.         dc.l  SA_Volume,100
  265.         dc.l  SA_Source,.file
  266.         dc.l  SA_Attrib,SDF_STOPLAST
  267.         dc.l  TAGEND
  268.  
  269. .file        FILENAME "GMS:demos/data/SND.Rambo"
  270.  
  271. ;===========================================================================;
  272.  
  273. ProgName:    dc.b  "Rambo Worm",0
  274. ProgAuthor:    dc.b  "Paul Manias",0
  275. ProgDate:    dc.b  "January 1998",0
  276. ProgCopyright:    dc.b  "DreamWorld Productions (c) 1996-1998.  Freely distributable.",0
  277. ProgShort:    dc.b  "Bob demo.",0
  278.         even
  279.  
  280.